package com.heima.article.controller.v1;


import com.heima.article.service.ApArticleService;
import com.heima.common.constants.ArticleConstants;
import com.heima.model.article.dtos.ArticleHomeDto;
import com.heima.model.common.dtos.ResponseResult;
import lombok.extern.slf4j.Slf4j;
import org.apache.yetus.audience.InterfaceAudience;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
@RequestMapping("/api/v1/article")
public class ArticleHomeController {

    @Autowired
    private ApArticleService apArticleService;



    @PostMapping("laod")
    public ResponseResult load(@RequestBody ArticleHomeDto dto){

        //ResponseResult load = apArticleService.load(dto, ArticleConstants.LOADTYPE_LOAD_MORE);
        ResponseResult load = apArticleService.load2(dto, ArticleConstants.LOADTYPE_LOAD_MORE,true);

        return load;
    }

    @PostMapping("laodmore")
    public ResponseResult loadnore(@RequestBody ArticleHomeDto dto){

        ResponseResult load = apArticleService.load(dto, ArticleConstants.LOADTYPE_LOAD_MORE);

        return load;
    }

    @PostMapping("laodnew")
    public ResponseResult loadnew(@RequestBody ArticleHomeDto dto){

        ResponseResult load = apArticleService.load(dto, ArticleConstants.LOADTYPE_LOAD_NEW);
        return load;
    }

}
